Namespace Actions.ActionItems
    <ActionItemWordAttribute("set")> _
    Public Class aiRsSet
        Inherits ActionItem

        Public Sub New(ByVal Owner As Action, ByVal Definition As Xml.XmlNode)
            MyBase.New(Owner, Definition)
        End Sub

        Public Overrides Sub Execute()
            Dim RsName As String = OwnerAction.InsertParams(Configuration.Attribute("recordset", "default"))
            Dim FieldName As String = OwnerAction.InsertParams(Configuration.Attribute("field", ""))
            Dim VarName As String = "@" + OwnerAction.InsertParams(Configuration.Attribute("what", FieldName))

            Dim rs As ADODB.Recordset = OwnerAction.Resources.Recordsets(RsName)
            Dim f As ADODB.Field = rs.Fields(FieldName)

            If Not OwnerAction.Parameters.ContainsKey(VarName) Then
                OwnerAction.Parameters.Add(VarName, New ActionParameter(VarName, ActionParameter.TypeEnum.tpString))
            End If
            OwnerAction.Parameters(VarName).Value = f.Value
        End Sub
    End Class
End Namespace